(function() {
    angular.module('app').controller('redNetCtrl', redNetCtrl);

    redNetCtrl.$inject = ['$rootScope', '$scope'];

    function redNetCtrl($rootScope, $scope) {

        var vm = this;

        // console.log('redNetCtrl loading js');

        vm.tab = 'daren';

        vm.nav = [];


        var clearShop = $rootScope.$on('redNet_daren_shop_EV', function(e, daren) {

            vm.tab = 'darenShop'

            vm.nav = [{
                text: '达人',
                handel: function() {

                    vm.tab = 'daren';

                    vm.nav.pop();
                }
            }, {
                text: '达人合作店铺',
                handel: function() {

                }

            }];
        });


        var clearShopProduct = $rootScope.$on('formShop_detail_EV', function(e, shopUid, shopName) {

            vm.tab = 'darenShopProd';

            vm.nav = [{
                text: '达人',
                handel: function() {

                    vm.tab = 'daren';

                    vm.nav.length = 0;

                }
            }, {
                text: '达人合作店铺',
                handel: function() {

                    vm.tab = 'darenShop';

                    vm.nav.pop();

                }
            }, {
                text: shopName + '-商品',
                handel: function() {

                }
            }];
        });


        var clearDarenTie = $rootScope.$on('redNet_daren_tie_EV', function() {

            vm.tab = 'darenTie';

            vm.nav = [{
                text: '达人',
                handel: function() {

                    vm.tab = 'daren';

                    vm.nav.pop();

                }
            }, {
                text: '帖子',
                handel: function() {


                }
            }];

        });


        var clearDarenTieProduct = $rootScope.$on('redNet_daren_tie_product_EV', function() {

            vm.tab = 'darenTieProduct';

            vm.nav = [{
                text: '达人',
                handel: function() {

                    vm.tab = 'daren';

                    vm.nav.length = 0;

                }
            }, {
                text: '帖子',
                handel: function() {

                    vm.tab = 'darenTie';

                    vm.nav.pop();

                }
            }, {
                text: '宝贝',
                handel: function() {


                }
            }];
        });


        $scope.$on('$destroy', function() {

            clearShop();
            clearShopProduct();
            clearDarenTie();
            clearDarenTieProduct();

        });
    }
})();
